<?php namespace App\Http\Controllers;

use App\Collect;
use Auth;

class BaseController extends Controller {

    /**
     * @param int $num
     * @param bool $lastest
     * @return array
     */
    protected function mycollect($num = 5, $lastest = true)
    {
        if( Auth::check() )
        {
            $uid = Auth::user()->id;

            if($lastest) //取最新的若干条数据
                $data = Collect::whereRaw('uid = :uid', [$uid])->take($num)->orderBy('time')->lists('title_id');
            else //取列表
                $data = Collect::whereRaw('uid = :uid', [$uid])->orderBy('time')->lists('title_id');

            return $data;
        }

        return [];
    }
}
